/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.datalogic.define.dao;

import cn.ekuma.data.dao.ModifiedLogDAO;
import cn.ekuma.epos.db.table.I_AttributeSet;

import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;
import com.openbravo.bean.AttributeSet;

/**
 *
 * @author Administrator
 */
public class AttributeSetDAO extends ModifiedLogDAO<AttributeSet>{

	
    public AttributeSetDAO(I_Session s) {
        super(s);
    }

    @Override
    public TableDefinition getTable() {
        return new TableDefinition(s,
                    "ATTRIBUTESET",
                    new Field[]{
                       new Field(I_AttributeSet.ID,Datas.STRING, Formats.STRING),
                       new Field(I_AttributeSet.NAME,Datas.STRING, Formats.STRING),
                       new Field(I_AttributeSet.LASTMODIFIED,Datas.TIMESTAMP, Formats.TIMESTAMP)
                     },
                    new int[]{0}
                    );
    }
    
    @Override
    public Class getSuportClass() {
       return AttributeSet.class;
    }

    public AttributeSet readValues(DataRead dr,AttributeSet obj) throws BasicException {
        if(obj==null)
    	  obj=new AttributeSet();
        obj.setId(dr.getString(1));
        obj.setName(dr.getString(2));
        obj.setLastModified(dr.getTimestamp(3));
        return obj;
    }

    @Override
    public void writeInsertValues(DataWrite dp, AttributeSet obj) throws BasicException {
                dp.setString(1, obj.getId());
                dp.setString(2, obj.getName());
                dp.setTimestamp(3, obj.getLastModified());
    }

}
